Strict

Import agfx

Global myAppScreen:TmyAppScreen

Class TAgfx_test_app Extends TFramework

	Method OnCreate:Int()
		
		
	
		Super.OnCreate()
	
		'DISPLAY.SetVirtualSize(320,480)
					
		myAppScreen = New TmyAppScreen		
		myAppScreen.Prepare()
		
		Return 0
	End Method

	
End


Class TmyAppScreen Extends TScreen
	
	Field sprite:TDragImage

	' START when app is created
	Method Start:Void()
	
		Self.name = "Test DragImage App"
		
		IMAGES.Load("ball.png", "BALL", True)	
		
		Self.sprite = New TDragImage()
		Self.sprite.Create("BALL")
		Self.sprite.position.Set(50,50)		
		Self.sprite.OnDragEnd = New SpriteDragEndCallback(Self.sprite)
	End Method
	
	' main app logic loop update
	Method Update:Void()

		Self.sprite.Update()
	End Method
	
	' main app render loop
	Method Render:Void()
		Cls 80,80,80
		Self.sprite.Draw()
	End Method
End


Class SpriteDragEndCallback Extends TCallback
	
	Field ball:TDragImage
	
	Method New(b:TDragImage)
		Self.ball = b
	End Method
	
	Method Call:Void()
		Print("Drag End with "+ball.name+" at "+ball.position.ToString())
	End Method
	
End



